#!/bin/bash

# Christina智能助手快速启动脚本

echo "🤖 Christina智能助手启动脚本"
echo "================================"

# 检查Docker是否安装
if ! command -v docker &> /dev/null; then
    echo "❌ Docker未安装，请先安装Docker"
    exit 1
fi

if ! command -v docker-compose &> /dev/null; then
    echo "❌ Docker Compose未安装，请先安装Docker Compose"
    exit 1
fi

# 检查环境变量
if [ -z "$DEEPSEEK_API_KEY" ]; then
    echo "⚠️  警告: DEEPSEEK_API_KEY环境变量未设置"
    echo "   AI功能可能无法正常工作"
    echo "   请设置: export DEEPSEEK_API_KEY=your-api-key"
    echo ""
fi

# 创建必要的目录
echo "📁 创建必要的目录..."
mkdir -p docker/mysql
mkdir -p docker/redis
mkdir -p docker/nginx
mkdir -p logs

# 设置权限
chmod +x start.sh
chmod +x stop.sh

echo "🚀 启动Christina智能助手..."

# 启动服务
docker-compose up -d

echo ""
echo "⏳ 等待服务启动..."
sleep 30

# 检查服务状态
echo "📊 检查服务状态..."
docker-compose ps

echo ""
echo "🎉 Christina智能助手启动完成！"
echo ""
echo "📡 服务地址:"
echo "   - 应用服务: http://localhost:8081"
echo "   - API文档: http://localhost:8081/api/swagger-ui.html"
echo "   - 健康检查: http://localhost:8081/api/v1/christina/health"
echo "   - RabbitMQ管理: http://localhost:15672 (christina/christina123)"
echo ""
echo "🧪 快速测试:"
echo "   curl http://localhost:8081/api/v1/christina/health"
echo ""
echo "📚 更多信息请查看 README.md"
echo ""
echo "🛑 停止服务: ./stop.sh"